﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace Restarty_SIPO3.Class
{
    class Sluzba
    {
        private string suma;
        public String KodSluzby { get; set; }
        public String NazovSluzby { get; set; }
        public String Znamienko { get; set; }
        public String CelkovaSuma
        {
            get
            {
                return suma.Replace(",", ".");
            }
            set
            {
                suma = value;
            }
        }

        internal ArrayList VytvorRetazce(Subor DataSubor)
        {
            String tmpStr = null;
            ArrayList PoleRetazcov = new ArrayList();
            int i = 0;
            foreach (Posta tmpPosta in DataSubor.PolePost)
            {
                foreach (Rajon tmpRajon in tmpPosta.Rajony)
                {
                    foreach (Zakaznik tmpZakaznik in tmpRajon.Zakaznici)
                    {
                        foreach (Sluzba tmpSluzba in tmpZakaznik.Sluzby)
                        {
                            tmpStr += "(0," + tmpSluzba.KodSluzby + ",''" + tmpSluzba.NazovSluzby + "'',''" + tmpSluzba.Znamienko + "''," + tmpSluzba.CelkovaSuma + ",''" + tmpZakaznik.IDZakaznika + "''),";
                            i++;
                            if (i > 500)
                            {
                                PoleRetazcov.Add(tmpStr.Substring(0, tmpStr.Length - 1));
                                tmpStr = null;
                                i = 0;
                            }
                        }
                    }
                    if (tmpStr != null)
                        PoleRetazcov.Add(tmpStr.Substring(0, tmpStr.Length - 1));
                    tmpStr = null;
                    i = 0;
                }
            }

            return PoleRetazcov;
        }
    }
}
